package com.es.business.citys;

import javax.servlet.http.HttpServletRequest;

import com.es.business.city.CityBiz;
import com.es.business.province.ProvinceBiz;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class CitysDeleteDoAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		CitysBiz citysBiz = new CitysBiz();
		CityBiz cityBiz = new CityBiz();
		String id = this.request.getParameter("citys_id");
		String code = this.request.getParameter("citys_code");
		
		int count = cityBiz.getCityCountByCitysCode(code);
		if(count != 0){
			result = "success";
			String message = "删除失败，有城市与该城市群相关联";
			this.request.setAttribute("message", message);
			return result;
		}
		
		boolean res = citysBiz.deleteCitysById(id);
		if(res == true){
			
			String message = "删除成功";
			this.request.setAttribute("message", message);
		}else{
			String message = "删除失败，请重新删除";
			this.request.setAttribute("message", message);
		}
		result = "success";
		return result;
	}
	 

}
